@mocketize as TestCase class decorator#297
@mocketize as TestCase class decorator#297wilhelmklopp wants to merge 2 commits intomindflayer:mainfrom
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #297 +/- ##
==========================================
- Coverage 98.72% 96.59% -2.14%
==========================================
Files 22 22
Lines 1020 1056 +36
==========================================
+ Hits 1007 1020 +13
- Misses 13 36 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I am not a very big fan of the "all in" approach. I'd like when there is magic, but only when it was explicitly summoned by the sorcerer. 🪄 I also see reasons for wanting this change. For instance when I am using Mocket in "strict mode", it'd be great if we could define it for the whole test class instead of every little function. Why don't we create a new decorator under This said, it's also missing tests, please add some meaningful ones (and maybe an example under the README). 🙏 |
|
|
@wilhelmklopp are you still willing to contribute to this? |
|
Closing this PR, no answer in a month. |



One nice thing you can do in httpretty is:
And then you don't need to do it for every single test method. Code in httpretty that handles this is here: https://github.com/gabrielfalcao/HTTPretty/blob/f9f012711597634d40066d144a36888b3addcc46/httpretty/core.py#L2066
Totally understand if this is a patch you would prefer not to accept, it probably feels a little "invasive" to mocket's core functionality. I'm happy to maintain a patch that works for me in my codebase.
(as with the previous PRs, this change is motivated by the httpretty->mocket migration i'm currently doing where we use the class level decorator quite heavily)
One annoying thing about the
@httpretty.activateimplementation is that you can't do@httpretty.activate(allow_net_connect=False)with the class decorator version. But with this PR you can do@mocketize(strict_mode=True).But as I said, I have no issue at all if you'd prefer to close this PR without merging :)